Skip to content

Comments

fix(atomic): When a citation title is null or undefined, there's a unhandled exception#6801

Merged
erocheleau merged 5 commits intomainfrom
SFINT-6544
Jan 12, 2026
Merged

fix(atomic): When a citation title is null or undefined, there's a unhandled exception#6801
erocheleau merged 5 commits intomainfrom
SFINT-6544

Conversation

@erocheleau
Copy link
Collaborator

@erocheleau erocheleau commented Dec 12, 2025

SFINT-6544

When the citation title is null or undefined, we try to call .trim() on it and it throws an exception preventing the correct rendering of the generated answer.

I fixed it both for the "deprecated" `generated-answer-common file and the newly migrated generated-answer-utils.

For the function in the generated-answer-utils file, I was able to add a unit test to cover this case.

For the -common code (which I think is no longer used by us, but kept for non-breaking changes?). I tested it manually with mocking a response from CRGA with a citation that would have no title, it correctly defaults to the localized string "No Title".

Copy link
Contributor

@SimonMilord SimonMilord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine but you sure we can't just mock a citation object with title=null and spy on an error being thrown?

Were you able to reproduce it and test the fix manually?

@erocheleau erocheleau marked this pull request as ready for review January 12, 2026 15:29
@erocheleau erocheleau requested a review from a team as a code owner January 12, 2026 15:29
Copilot AI review requested due to automatic review settings January 12, 2026 15:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes an unhandled exception that occurs when a citation title is null or undefined in generated answers. The fix uses the nullish coalescing operator (??) to safely handle these cases before calling .trim() on the title.

Changes:

  • Added null/undefined safety check using nullish coalescing operator in two locations
  • Added test coverage for the missing title scenario

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/atomic/src/components/common/generated-answer/generated-answer-utils.ts Added nullish coalescing operator to safely handle null/undefined titles before trimming
packages/atomic/src/components/common/generated-answer/generated-answer-common.tsx Applied the same null safety fix to the getCitation method
packages/atomic/src/components/common/generated-answer/generated-answer-utils.spec.ts Added test case to verify fallback title is applied when title is missing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@erocheleau erocheleau requested a review from mmitiche January 12, 2026 16:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@erocheleau erocheleau enabled auto-merge January 12, 2026 18:57
@erocheleau erocheleau added this pull request to the merge queue Jan 12, 2026
Merged via the queue into main with commit 4a8cd98 Jan 12, 2026
98 checks passed
@erocheleau erocheleau deleted the SFINT-6544 branch January 12, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants